<?php
namespace app\api\controller\template;
use app\api\service\template\TemplateService;
use think\facade\Request;
use think\facade\Log;
class Event
{
    protected $Service;
    public function __construct()
    {
        $this->Service = TemplateService::getInstance();
    }

    /**
     * @auth ('查询模板','模板推送')
     * @return \think\response\Json
     */
    public function getTemplate(){
        $list = $this->Service->getTemplate();
        return writeJson(200,$list,'success');
    }

    /**
     * @auth ('weixin验证token','模板推送')
     * @return \think\response\Json
     */
    public function verification(){
        $echoStr = $this->Service->verification();
        return (int)$echoStr;
    }

    /**
     * @auth ('订阅关注、取关','模板推送')
     * @return \think\response\Json
     */
    public function subscribe(){
        $result = $this->Service->subscribe();
        return $result;
    }

    /**
     * @auth ('查询关注用户','模板推送')
     * @return \think\response\Json
     */
    public function getFollowUsers(){
        $result = $this->Service->getFollowUsers();
        return writeJson(200,$result,'success');
    }

    /**
     * @auth ('推送模板','模板推送')
     * @return \think\response\Json
     */
    public function pushTemplate(){
        $params = Request::get();
        $result = $this->Service->pushTemplate($params);
        return writeJson(200,$result,'success');
    }

    /**
     * @auth ('推送模板','模板推送')
     * @return \think\response\Json
     */
    public function pushTagTemplate(){
        $params = Request::get();
        $result = $this->Service->pushTagTemplate($params);
        return writeJson(200,$result,'success');
    }

    /**
     * @return void
     */
    public function setTagUser()
    {
        $result = $this->Service->setTagUser();
        return writeJson(200,$result,'success');
    }
}
